package com.dci.controller.schedule;

import com.dci.model.schedule.ProgressUnit;
import com.dci.model.schedule.ProjectTeamManagement;
import com.dci.result.ResultInfo;
import com.dci.service.schedule.ProjectTeamService;
import com.dci.util.UUIDBuild;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Title: null.java
 * @Package com.dci.controller.project
 * @Description: 项目组管理
 * @author: 张星亮
 * @date: 2019/4/21
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 * 注意：本内容仅限于姑苏区政府大数据中心内部传阅，禁止外泄以及用于其他的商业目
 */
@Controller
@RequestMapping("/team")
public class ProjectTeamController {

    @Resource
    private ProjectTeamService projectTeamService;

    /**
     * 新增项目组
     *
     * @param name
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @PostMapping("/add")
    @ResponseBody
    public ResultInfo add(@RequestParam("name") String name) {
        ProjectTeamManagement projectTeamManagement = ProjectTeamManagement.builder().id(UUIDBuild.getUUID()).name(name).build();
        return projectTeamService.add(projectTeamManagement);
    }

    /**
     * 删除项目组
     *
     * @param id
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @PostMapping("/delete")
    @ResponseBody
    public ResultInfo delete(@RequestParam("id") String id) {
        return projectTeamService.delete(id);
    }

    /**
     * 修改项目组
     *
     * @param projectTeamManagement
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @PostMapping("/edit")
    @ResponseBody
    public ResultInfo edit(@RequestBody ProjectTeamManagement projectTeamManagement) {
        return projectTeamService.edit(projectTeamManagement);
    }

    /**
     * 查询所有项目组
     *
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @PostMapping("/select")
    @ResponseBody
    public List<ProjectTeamManagement> select() {
        return projectTeamService.select();
    }

    /**
     * 查询所有建设项目
     *
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @PostMapping("/selectUnit")
    @ResponseBody
    public List<ProgressUnit> selectUnit() {
        return projectTeamService.selectUnit();
    }
}
